package com.hegongda.service.impl;

import com.hegongda.bean.EChar;
import com.hegongda.dao.ECharDao;
import com.hegongda.service.ECharService;
import com.hegongda.utils.BeanFactory;
import java.sql.SQLException;
import java.util.List;

public class ECharServiceImpl implements ECharService {
    private ECharDao ed = BeanFactory.newInstance(ECharDao.class);

    @Override
    public double[][] fundThisYear() {
        List<EChar> eChars = null;
        double[][] intes = {{0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0}};
        try {
            eChars = ed.fundThisYear();
//            [
//                ['product', '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
//                ['未付款', 41.1, 30.4, 65.1, 53.3, 83.8, 98.7, 41.1, 30.4, 65.1, 53.3, 83.8, 98.7],
//                ['已付款', 86.5, 92.1, 85.7, 83.1, 73.4, 55.1, 86.5, 92.1, 85.7, 83.1, 73.4, 55.1],
//                ['已完成', 24.1, 67.2, 79.5, 86.4, 65.2, 82.5, 24.1, 67.2, 79.5, 86.4, 65.2, 82.5]
//            ]
            for(int i = 0;i < eChars.size();i++){
                int a = eChars.get(i).getMon()-1;
                int b = eChars.get(i).getState();
                if (b == 3){
                    b -= 1;
                }
                intes[b][a] = eChars.get(i).getTotalCount();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return intes;
    }

}